import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    /*  {
       path: '/home',
       name: 'home',
       component: HomeView,
     }, */
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/LoginView.vue'),
    }, {
      path: '/Navigation',
      name: 'Navigation',
      component: () => import('../views/RBAC/System/NavigationView.vue'),
      children: [
        {
          path: '/AddUser',
          name: 'AddUser',
          component: () => import('../views/RBAC/User/AddUserView.vue'),
        }, {
          path: '/GetUser',
          name: 'GetUser',
          component: () => import('../views/RBAC/User/GetUserView.vue'),
        }, {
          path: '/Update',
          name: 'Update',
          component: () => import('../views/RBAC/User/UpdateView.vue'),
        },
        {
          path: '/AddRole',
          name: 'AddRole',
          component: () => import('../views/RBAC/Role/AddRoleView.vue'),
        },
        {
          path: '/RoleList',
          name: 'RoleList',
          component: () => import('../views/RBAC/Role/RoleListView.vue'),
        },
        {
          path: '/MenuList',
          name: 'MenuList',
          component: () => import('../views/RBAC/Menu/MenuListView.vue'),
        },
        {
          path: '/AddMenu',
          name: 'AddMenu',
          component: () => import('../views/RBAC/Menu/AddMenuView.vue'),
        },
        {
          path: '/RoleMenuList',
          name: 'RoleMenuList',
          component: () => import('../views/RBAC/Menu/RoleMenuListView.vue'),
        }
        , {
          path: '/System',
          name: 'System',
          component: () => import('../views/RBAC/System/SystemView.vue'),
        }
        , {
          path: '/Role',
          name: 'Role',
          component: () => import('../views/RBAC/System/RoleView.vue'),
        }
        , {
          path: '/Menu',
          name: 'Menu',
          component: () => import('../views/RBAC/System/MenuView.vue'),
        }
        , {
          path: '/User',
          name: 'User',
          component: () => import('../views/RBAC/System/UserView.vue'),
        },
        {
          path: '/MenuRecursive',
          name: 'MenuRecursive',
          component: () => import('../views/RBAC/System/MenuRecursive.vue'),
        }, {
          path: '/AddLeave',
          name: 'AddLeave',
          component: () => import('../views/RBAC/Leave/AddLeaveView.vue'),
        }
        , {
          path: '/LeaveList',
          name: 'LeaveList',
          component: () => import('../views/RBAC/Leave/LeaveListView.vue'),
        },{
          path: '/A',
          name: 'A',
          component: () => import('../views/Zyy/A.vue'),
        },
      
      ]
      }
     
  ],
})


//路由守卫 beforeEach：在路由跳转之前进行判断111
// router.beforeEach((to, from, next) => {
//   if (to.path === '/') {
//     next()
//   } else {
//     //判断是否有token
//     const token = localStorage.getItem('token')
//     //如果没有token，则跳转到登录页面
//     if (!token) {
//       next('/')
//     } else {
//       //如果有token，则放行
//       next()
//     }
//   }
// })
export default router
